<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Kalamazoo Animal Rescue - List Event Pet Schedule</TITLE>

<META NAME="Author" CONTENT="Cayce Wilcox-York - York Systems Group">
<META HTTP-EQUIV="Expires" CONTENT="Tuesday, 26 March 2002 08:00:00 GMT">

</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#800000">
<H2>Event Pet List</H2>
<BR CLEAR=ALL>
<BR>


<?php


include($_SERVER['DOCUMENT_ROOT'] ."/includes/db.php");

				// Connect to the database server
dbConnect('kar_web1');   	// Use function in db.php to connect

// Join data from four tables so as to get name of pets, foster, event & appointment.
// Had problems trying to set date >= $today which equaled date("Y-m-d")
//  mySQL function now() seems to working great.


// Tried including store items in this as well but because eventID=0 for store items
// and there is not a table entry in Events for store, schedule.eventID=events.eventID
// left out all store animals.  

	$result = @mysql_query("SELECT * FROM events, eventPets, cats, dogs, volunteers
				WHERE (eventPets.tagNum=cats.tagNum
				OR eventPets.tagNum=dogs.tagNum)
				AND
				eventPets.eventID=events.eventID AND
				(cats.volunteer_id=volunteers.volunteer_id
				OR dogs.volunteer_id=volunteers.volunteer_id)
				AND (cats.pet_status = 'v' OR dogs.pet_status = 'v')
				AND events.eventDate >= now()
				ORDER BY events.eventDate, volunteers.name ASC");

if (!$result) {
  echo("<p>Error performing query: " . mysql_error() . "</p>");
  exit();
}  // end if

echo("<CENTER><TABLE border cellpadding=3>");
echo("<TH><B>Pet Name</B></TH>");
echo("<TH><B>Cat/Dog</B></TH>");
echo("<TH><B>Foster Home</B></TH>");
echo("<TH><B>Date</B></TH>");
echo("<TH><B>Time</B></TH>");
echo("<TH><B>Event</B></TH></TR>");
$shade = 1;

while ( $row = mysql_fetch_array($result) )  {			// while there is data
   $id = $row["tagNum"];
   $name =  $row["pet_name"];
   $eventName = $row["eventName"];
   $foster_home = $row["name"];
//   $petType = $row["pet_type"];
   if ($petType == "c" )
	{ $petType = "cat";} 
	else
	{$petType="dog";}

   $date = $row["eventDate"];
   	list($year, $month, $day) = explode("-", $date);
	$showDate = date("l, F j, Y", mktime(0,0,0,$month, $day, $year));
   $a_time = $row["arrive_time"];
   $b_time = $row["depart_time"];
if ($shade) {
	$clr = "#ffcccc";
	$shade=0;
	} else {
	$clr = "#ccffcc";
	$shade=1; 
	}

	echo("<TR bgcolor=".$clr.">");
	echo ("<TD>". $name."</TD>");
//	echo ("<TD>". $petType."</TD>");
	echo ("<TD>". $foster_home."</TD>");
	echo ("<TD>". $showDate."</TD>");
	echo ("<TD>". $a_time. " - " . $b_time . "</TD>");
	echo ("<TD>". $eventName . "</TD></TR>");
}  // end while

echo("</TABLE></CENTER>");

?>
<BR>

</FORM>
<BR><BR>
Return to <a href="sched_admin.php">Scheduler Admin Page</a><BR>
</CENTER>


</BODY>
</HTML>
